﻿<inter:PluginConfigForm x:Class="Convertor.Plugin.InsertText.ConfigForm"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:inter="clr-namespace:Convertor.Interface;assembly=Convertor.Interface"
             xmlns:sm="clr-namespace:Wpf.CommonTools.SystemExtension;assembly=Wpf.CommonTools"
             xmlns:conv="clr-namespace:Wpf.CommonTools.Converter;assembly=Wpf.CommonTools"
             xmlns:local="clr-namespace:Convertor.Plugin.InsertText"
             xmlns:sys="clr-namespace:System;assembly=mscorlib"
             xmlns:regex="clr-namespace:System.Text.RegularExpressions;assembly=System"
             mc:Ignorable="d"
             DataContext="{Binding RelativeSource={RelativeSource Self}}"
             Loaded="UserControl_Loaded_1">
    <inter:PluginConfigForm.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/Convertor;component\Assets\Style.xaml"/>
                <ResourceDictionary Source="Assets\Lang\StringResource.zh.xaml"/>
                <ResourceDictionary Source="Assets\Lang\StringResource.en.xaml"/>
            </ResourceDictionary.MergedDictionaries>
            <ObjectDataProvider x:Key="InsertTypes" 
                        MethodName="GetValues" ObjectType="{x:Type sys:Enum}">
                <ObjectDataProvider.MethodParameters>
                    <x:Type TypeName="local:InsertTypes"/>
                </ObjectDataProvider.MethodParameters>
            </ObjectDataProvider>
            <ObjectDataProvider x:Key="StartTypes" 
                        MethodName="GetValues" ObjectType="{x:Type sys:Enum}">
                <ObjectDataProvider.MethodParameters>
                    <x:Type TypeName="local:StartTypes"/>
                </ObjectDataProvider.MethodParameters>
            </ObjectDataProvider>
            <ObjectDataProvider x:Key="CalculateTypes" 
                        MethodName="GetValues" ObjectType="{x:Type sys:Enum}">
                <ObjectDataProvider.MethodParameters>
                    <x:Type TypeName="local:CalculateTypes"/>
                </ObjectDataProvider.MethodParameters>
            </ObjectDataProvider>
            <local:EndConvertor x:Key="EndConvertor"></local:EndConvertor>
            <conv:FindUILanguageConverter x:Key="FindUILanguageConverter"/>
        </ResourceDictionary>
    </inter:PluginConfigForm.Resources>
    <Grid MinWidth="500" MaxWidth="800">
        <DockPanel DataContext="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type inter:PluginConfigForm}}, Path=Config}">
            <ComboBox x:Name="cbInsertType" HorizontalAlignment="Left" DockPanel.Dock="Top" MinWidth="100" 
                      SelectedIndex="0"
                      ItemsSource="{Binding Source={StaticResource InsertTypes}}"
                      SelectedItem="{Binding Path=InsertType}">
                <ComboBox.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding Path=., Converter={StaticResource FindUILanguageConverter}, ConverterParameter='Plugin_InsertText_InsertType_'}"/>
                    </DataTemplate>
                </ComboBox.ItemTemplate>
            </ComboBox>
            <DockPanel DockPanel.Dock="Top">
                <ComboBox MaxWidth="200" DockPanel.Dock="Right" 
                          ItemsSource="{Binding Source={StaticResource StartTypes}}"
                          SelectedIndex="0"
                          SelectedItem="{Binding Path=StartType}">
                    <ComboBox.ItemTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Path=., Converter={StaticResource FindUILanguageConverter}, ConverterParameter='Plugin_InsertText_StartType_'}"/>
                        </DataTemplate>
                    </ComboBox.ItemTemplate>
                </ComboBox>
                <ComboBox DockPanel.Dock="Right"
                          ItemsSource="{Binding Source={StaticResource CalculateTypes}}"
                          SelectedIndex="0"
                          SelectedItem="{Binding Path=CalculateType}">
                    <ComboBox.ItemTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Path=., Converter={StaticResource FindUILanguageConverter}, ConverterParameter='Plugin_InsertText_CalculateType_'}"/>
                        </DataTemplate>
                    </ComboBox.ItemTemplate>
                </ComboBox>
                <AdornerDecorator DockPanel.Dock="Right" MinWidth="150" Visibility="{Binding Path=InsertType, Converter={StaticResource EndConvertor}, ConverterParameter=1}">
                    <TextBox Text="{Binding Path=Length, UpdateSourceTrigger=PropertyChanged}">
                        <sm:WatermarkService.Titlemark>
                            <TextBlock Text="{DynamicResource Plugin_InsertText_Length}" TextAlignment="Right"></TextBlock>
                        </sm:WatermarkService.Titlemark>
                    </TextBox>
                </AdornerDecorator>
                <AdornerDecorator DockPanel.Dock="Right" MinWidth="150" Visibility="{Binding Path=InsertType, Converter={StaticResource EndConvertor}, ConverterParameter=0}">
                    <TextBox Text="{Binding Path=Length, UpdateSourceTrigger=PropertyChanged}">
                        <sm:WatermarkService.Titlemark>
                            <TextBlock Text="{DynamicResource Plugin_InsertText_StopPosition}" TextAlignment="Right"></TextBlock>
                        </sm:WatermarkService.Titlemark>
                    </TextBox>
                </AdornerDecorator>
                <AdornerDecorator Grid.Column="0" MinWidth="160" DockPanel.Dock="Left">
                    <TextBox Text="{Binding Path=StartPosition, UpdateSourceTrigger=PropertyChanged}">
                        <sm:WatermarkService.Titlemark>
                            <TextBlock Text="{DynamicResource Plugin_InsertText_StartPosition}" TextAlignment="Right"></TextBlock>
                        </sm:WatermarkService.Titlemark>
                    </TextBox>
                </AdornerDecorator>
            </DockPanel>
            <AdornerDecorator DockPanel.Dock="Top"
                              Visibility="{Binding Path=InsertType, Converter={StaticResource EndConvertor}, ConverterParameter=2}">
                <TextBox x:Name="tbInsertText" AcceptsReturn="True" AcceptsTab="True"
                         Text="{Binding Path=InsertText, UpdateSourceTrigger=PropertyChanged}">
                    <sm:WatermarkService.Titlemark>
                        <TextBlock Text="{DynamicResource Plugin_InsertText_InsertText}" TextAlignment="Right" VerticalAlignment="Bottom"></TextBlock>
                    </sm:WatermarkService.Titlemark>
                </TextBox>
            </AdornerDecorator>
            <TextBlock Style="{StaticResource InfoStyle}" DockPanel.Dock="Top" Text="{Binding Path=ToolTip}"/>
        </DockPanel>
    </Grid>
</inter:PluginConfigForm>
